package com.zt.bus.shiro.filter;

import com.monkeyk.os.oauth.shiro.OAuth2Filter;
import com.zt.servlet.ReqBean;
import javax.servlet.FilterChain;
import javax.servlet.ServletRequest;
import javax.servlet.ServletResponse;
import javax.servlet.http.HttpServletRequest;

public class BusOAuth2Filter extends OAuth2Filter {

    @Override
    protected void executeChain(ServletRequest request, ServletResponse response, FilterChain chain) throws Exception {
        // 验证通过，设置当前用户id
        ReqBean reqBean = (ReqBean) request.getAttribute(ReqBean.NAME);
        if (reqBean != null) {// 这里可能没有经过MainFilter
            reqBean.setUserId(((HttpServletRequest) request).getUserPrincipal().getName());
            // System.out.println(GlobalInput.getCurrentUserId());
        }
        super.executeChain(request, response, chain);
    }
}
